  precision mediump float;
    varying vec2 v_texCoord; 
    uniform sampler2D u_image0; 
    uniform sampler2D u_image1; 
    uniform float thresholds[18]; 
    uniform float colors[72]; 
    uniform float factor; 
    uniform bool hasTwoTextures; // 判断是否有两个纹理
    uniform int thresholdsStart; // 纹理的起始索引
    uniform int thresholdsEnd;  // 纹理的结束索引

    void main() {
        vec4 renderColor = vec4(0.0, 0.0, 0.0, .0);
        float expandedColor;

        if (hasTwoTextures) {
            float r1 = texture2D(u_image0, v_texCoord).r; 
            float r2 = texture2D(u_image1, v_texCoord).r; 
            float factorColor = mix(r1, r2, factor); 
            expandedColor = factorColor * 255.0;  
        } else {
            float r = texture2D(u_image0, v_texCoord).r;
            expandedColor = r * 255.0;
        }

        for (int i = 0; i < 17; i++) {
            if (i <= thresholdsStart || i > thresholdsEnd) { 
                continue;
            }
            if (expandedColor >= thresholds[17]) {
                renderColor = vec4(0.0, 0.0, 0.0, 1.0);
                break;
            }
            if (expandedColor >= thresholds[i] && expandedColor < thresholds[i + 1]) {
                renderColor.r = colors[i * 4];
                renderColor.g = colors[i * 4 + 1];
                renderColor.b = colors[i * 4 + 2];
                renderColor.a = colors[i * 4 + 3];
                break;
            }
        }

        gl_FragColor = renderColor;
    }